<template>
	<view class="main">
		<!-- get:app/wechat/pwdLogin?userName=1111&password=2222 -->
		<view class="title">劳动力信息系统</view>
		<view class="uForm">
					
			<u-form :model="form" ref="uForm" :label-style="{'color':'white'}">
						<u-form-item label="账号" prop="username" >
							<!-- <u-icon name="man-add-fill" color="#2979ff" size="28" class="uIcon1"></u-icon> -->
							<u-input class="input" v-model="form.username" type="text" placeholder="请输入用户名"/>
						</u-form-item>
						<u-form-item label="密码" prop="password">
							<!-- <u-icon name="lock-fill" color="#2979ff" size="28" class="uIcon2"></u-icon> -->
							<u-input class="input" v-model="form.password" type="password" placeholder="请输入密码"/>
						</u-form-item>
			</u-form>
			
		</view>
		<view class="uBottom">
			<u-button @click="submit"  type="primary" size="default">登录</u-button>
		</view>
		
	</view>
</template>

<script>
	import api from "../../api/routes.js";
	export default {
		onReady() {
				this.$refs.uForm.setRules(this.rules);
			},
		data(){
				
			return{
				form: {
					username: '',
					password: '',
				},
				rules: {
					username: [
									{ 
										required: true, 
										message: '请输入用户名', 
										trigger: ["blur", "change"],
									}
								],
					password: [
									{
										required: true, 
										message: '请输入密码', 
										trigger: ["blur", "change"],
									}
								]
				}
			}
		},
			
		methods:{
			async submit(){
				console.log(this.form,"登录");
				const res =await this.$myRequest({
					url: api.systemLogin,
					method: "GET",
					data: {
						userName:this.form.username,
						password:this.form.password,
					
					},
				});
				console.log(res,"denglu");
				if(res.data.code==0){
					wx.setStorageSync("userInfomation",res.data.member);
										
					wx.setStorageSync("token",res.data.token);
					
					 
					wx.showToast({
						title: res.data.msg,
						icon: 'none'
					})
					
					setTimeout(() => {
						uni.navigateTo({
						    url: "/pages/humanSociety/dataStatistics",
						});
						this.form.username='';
						this.form.password='';
						wx.hideLoading()
					}, 1500)
				}
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.main{
		width: 100%;
		height: 100vh;
		background-image: url('http://m.qpic.cn/psc?/V10IS6xM0I2DX0/ruAMsa53pVQWN7FLK88i5kfd8TfbqAKB1pl5OOnzqCBYchThiDgvQx.OX5Yoh3Q2gfNpNMSPcaQNlpxezWIVyPg9d.nCX4.XCGgm*XJa07o!/mnull&bo=OAQjCQAAAAADBzQ!&rf=photolist&t=5');
		background-repeat: no-repeat;
		background-size: cover;
	}
	.title{
		font-size: 20px;
		margin: 0 auto;
		color: white;
		text-align: center;
		line-height: 20px;
		padding: 80px 0 50px 0;
	}
	.uForm{
		width: 90%;		
		margin: 0 auto;
		color: white;
		 /deep/ .input{//注意/deep/深度作用选择器。 /deep/报错的话可以试试::v-deep 					
					.u-input__input{
						color: white!important;//颜色在这里
					}
				}
		
	}
	.uBottom{
		
		color: white;
		margin: 30px 10px 0 10px;
		
	}
	.uIcon1{
		position: fixed;
		top: 190px;
		left: 42px;
	}
	.uIcon2{
		position: fixed;
		top: 240px;
		left: 42px;
	}
</style>